#include <cstdlib>
#include <memory>

void testcase1_func1(void*) {}
void testcase1_func2(int i) {}
void testcase1_func2(void* i) {}
void testcase1_overloadProblems( )
{	
	testcase1_func1(0);			//if there is no overload of int, 0 and NULL are used as pointer
	testcase1_func1(NULL);		
	testcase1_func2(0);			//calling testcase1_func(int i)
#ifndef __GNUC__
	testcase1_func2(NULL);		//calling testcase1_func(int i), 
								//gcc 4.9.2 does not like this, not sure earlier version
#endif
}

void testcase2_func(void* i) {}
template <typename T>
void testcase2_funcTemp(T t)
{
	testcase2_func(t);
}

void testcase2_errorUsingNULL()
{
	testcase2_func(NULL);

	//template type deduction will deduces NULL to int, so no proper testcase2_func available.
	//testcase2_funcTemp(NULL);		//won't boot. 
	testcase2_funcTemp(nullptr);
}

int Test_I08_PreferNullptrTo0_NULL(int, char**)
{
	testcase1_overloadProblems();
	testcase2_errorUsingNULL();

	return 0;
}

/*
Things to Remember
- Prefer nullptr to 0 and NULL.
- Avoid overloading on integral and pointer types.
*/